<style tyle="text/css">
  .mt10 {
    margin-top: 10px
  }
  .dropdown-menu .p5_15:hover {
    background-color: #edf1f2 !important;
    background-image: none;
    filter: none;
    cursor: pointer;
  }
  .p5_15 {
    padding: 5px 15px;
  }
  .dropdown-btn {
    float: left;
    margin-top: 3px;
  }
  .dropdown-menu li {
    white-space: nowrap;
  }
  .quick-btn {
    padding-top: 8px;
  }
  .font-color {
    color: #428bca;
  }
  .red_font {
    color: #f00;
  }
  .chechbox-style {
    width: 14px;
    font-size: 17px;
    padding-top: 1px;
  }
  .role_style {
    margin-bottom:2px;
    margin-right:5px;
    width:110px;
  }
  .yuio {
    padding-bottom: 5px;
    padding-top: 0px;
    padding-left: 0px;
  }
</style>
<div class="col-sm-12 mt20">
  <!-- 页面头部搜索条件 -->
  <div class="panel panel-body">
    <div class="col-lg-12">
      <div class="col-lg-2">
        <label class="form-control-static pull-right">查询时间段：</label>
      </div>
      <div class="col-lg-2-4">
        <div class="input-group" ng-click="dateOpen($event, date)">
          <input type="text" class="form-control" datepicker-popup="yyyy-MM-dd" ng-model="date.lable" is-open="date.opened"
            placeholder="开始时间" ng-required="true" close-text="关闭" current-text="今天" clear-text="清除" readonly/>
          <span class="input-group-btn">
            <button type="button" class="btn btn-default">
              <i class="glyphicon glyphicon-calendar"></i>
            </button>
          </span>
        </div>
      </div>
      <div class="col-lg-2-4">
        <div class="input-group" ng-click="dateOpen($event, date1)">
          <input type="text" class="form-control" datepicker-popup="yyyy-MM-dd" ng-model="date1.lable" is-open="date1.opened" 
            placeholder="结束时间" ng-required="true" close-text="关闭" current-text="今天" clear-text="清除" readonly/>
          <span class="input-group-btn">
            <button type="button" class="btn btn-default">
              <i class="glyphicon glyphicon-calendar"></i>
            </button>
          </span>
        </div>
      </div>

      <a class="btn btn-xs btn-link quick-btn font-color" ng-click="today()">今天</a>
      <a class="btn btn-xs btn-link quick-btn font-color" ng-click="yesterday()">昨天</a>
      <a class="btn btn-xs btn-link quick-btn font-color" ng-click="thisWeek()">本周</a>
      <a class="btn btn-xs btn-link quick-btn font-color" ng-click="lastWeek()">上周</a>
      <a class="btn btn-xs btn-link quick-btn font-color" ng-click="thisMonth()">本月</a>
      <a class="btn btn-xs btn-link quick-btn font-color" ng-click="lastMonth()">上月</a>

    </div>
    <div class="col-lg-12 mt10">
      <div class="col-lg-2">
        <label class="control-label pull-right">选择维度：</label>
      </div>
      <div class="col-lg-10">
        <span ng-repeat="item in resultList" ng-show="!fromData.searchType" style="margin-right: 15px">
          <label ng-click="item.check = !item.check">
            <i class="fa fa-check-square chechbox-style font-color" ng-show="item.check"/>
            <i class="fa fa-square-o chechbox-style font-color" ng-show="!item.check"/> 
            <span style="vertical-align: text-bottom">{{item.label}}</span>
          </label>
        </span>

        <div class="btn-group" ng-show="fromData.searchType">
          <label class="btn btn-sm btn-default role_style" ng-model="fromData.group_rule" ng-repeat="info in fixedList" 
          btn-radio=info.context>{{info.title}} 
            <i class="glyphicon glyphicon-remove text-active red_font pull-right" ng-if="$index!=0" ng-click="delete($index,info.id)"/>
          </label>
        </div>
        <a class="btn btn-xs btn-link font-color yuio" ng-show="!fromData.searchType" ng-click="fromData.searchType = true">返回</a>
        <a class="btn btn-xs btn-link font-color yuio" ng-show="!fromData.searchType" ng-click="addFixed()">保存勾选项</a>
        <a class="btn btn-xs btn-link font-color" style="padding-bottom: 2px" ng-show="fromData.searchType" ng-click="setFixed()">自定义维度</a>
      </div>
    </div>
    <div class="col-lg-12 mt10">
      <div class="col-lg-2 pull-right">
        <button type="button" class="btn btn-primary form-control" ng-click="downloadExl()">导出Excel</button>
        <a id="dlink" download="{{excelTitle}}.xlsx" ng-show="false"></a>
      </div>
      <div class="col-lg-2 pull-right">
        <button type="button" class="btn btn-info search form-control" ng-click="load()">立即搜索</button>
      </div>
    </div>
  </div>

  <!-- 网速太慢,画圈等 -->
  <h3 class="col-sm-12 text-center" ng-show="fromData.loading">
    <i class="fa fa-spin fa-spinner hide show inline"/>
  </h3>

  <!-- 统计数据 -->
  <div class="panel panel-default table-responsive" ng-show="!fromData.loading" style="min-height: 200px;">
    <h3 class="col-sm-12 text-center" ng-show="fromData.selectedList.length == 0">
      <i class="fa fa-coffee"/> 无统计数据
    </h3>

    <table id="tableData" class="table table-striped table-bordered" ng-show="fromData.selectedList.length != 0">
      <thead>
        <tr>
          <th class="text-right" ng-repeat="item in fromData.selectedList" ng-style="setStyle(item)">
            <div class="dropdown-btn">{{item.label}}</div>
            <div class="btn-group dropdown" dropdown="" ng-if="filters[item.value]" ng-class="{'open': item.open}">
                <!--   dropdown-toggle="" -->
              <button class="btn btn-default btn-xs" style="width: 24px;" ng-click="dropdownMenu(item, fromData.selectedList)">
                <!-- <span class="caret"/> -->
                <i class="fa fa-filter" ng-show="!item.isfilter"/>
                <i class="glyphicon glyphicon-filter" ng-show="item.isfilter"/>
              </button>
              <ul class="dropdown-menu " ng-class="{true: 'pull-left', false: 'pull-right'}[$index==0 && fromData.selectedList.length > 2]">
                <li class="p5_15" ng-repeat="(key, flag) in filters[item.value]" ng-click="filterType(key, flag, filters[item.value], item)">
                  <i class="fa fa-check-square chechbox-style" ng-show="flag"/>
                  <i class="fa fa-square-o chechbox-style" ng-show="!flag"/> {{key}}
                  <!-- <div class="i-checks m-b-none"> -->
                    <!-- <input type="checkbox" ng-model="flag"><i></i>{{key}} -->
                  <!-- </div> -->
                </li>
                <li class="text-center" style="padding-top: 3px">
                  <button class="btn btn-default btn-xs" style="margin-right: 3px" ng-click="selectFlag(false,filters[item.value],item)">全选</button>
                  <button class="btn btn-default btn-xs" style="margin-right: 3px" ng-click="selectFlag(true,filters[item.value],item)">清空</button>
                  <button class="btn btn-default btn-xs" ng-click="item.open = false">关闭</button>
                </li>
              </ul>
            </div>
          </th>
          <th class="text-center" ng-show="fromData.shown" style="min-width: 80px">总金额</th>
          <th class="text-center" ng-show="fromData.shown" style="min-width: 90px">购买数量</th>
          <th class="text-center" ng-show="fromData.shown" style="min-width: 90px">退票数量</th>
          <th class="text-center" ng-show="!fromData.shown" style="min-width: 90px">使用数量</th>
          <th class="text-center" style="min-width: 90px">补贴总额</th>
          <th class="text-center" style="min-width: 90px">操作</th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="info in saleList | filter: {'show': true}">
          <td ng-repeat="item in fromData.selectedList" class={{item.align}} style="vertical-align: middle;">
            <span ng-show="item.more != 1">{{info[item.more]}}<br/></span>
            <span ng-show="item.value != 'unit_price' && item.value != 'platform_order_actual_subsidy' && item.showCode">{{info[item.value]}}</span>
            <span ng-show="item.value == 'unit_price' && item.showCode">{{info[item.value] / 100 | currency : '￥'}}</span>
            <span ng-show="item.value == 'platform_order_actual_subsidy' && item.showCode">{{info[item.value] / 100 | currency : '￥'}}</span>
          </td>
          <td class="text-center" style="vertical-align: middle;" ng-show="fromData.shown">{{info.down_price / 100 | currency : '￥'}}</td>
          <td class="text-center" style="vertical-align: middle;" ng-show="fromData.shown">{{info.buy}}</td>
          <td class="text-center" style="vertical-align: middle;" ng-show="fromData.shown">{{info.back}}</td>
          <td class="text-center" style="vertical-align: middle;" ng-show="!fromData.shown">{{info.used}}</td>
          <td class="text-center" style="vertical-align: middle;">{{info.total_platform_order_actual_subsidy / 100 | currency : '￥'}}</td>
          <td class="text-center" style="vertical-align: middle;">
            <button class="btn btn-primary btn-sm" ng-click="downloadDetail(info)">
              <i class="fa fa-spin fa-spinner inline" ng-show="info.waiting"></i>
              <span ng-show="!info.waiting">导出明细</span>
            </button>
          </td>
        </tr>
        <tr>
          <td ng-repeat="item in fromData.selectedList" class="text-center">
            <span ng-show="$index == 0">合计</span>
          </td>
          <td class="text-center" ng-show="fromData.shown">{{fromData.total.price / 100 | currency : '￥'}}</td>
          <td class="text-center" ng-show="fromData.shown">{{fromData.total.buy}}</td>
          <td class="text-center" ng-show="fromData.shown">{{fromData.total.back}}</td>
          <td class="text-center" ng-show="!fromData.shown">{{fromData.total.used}}</td>
          <td class="text-center">{{fromData.total.subsidy / 100 | currency : '￥'}}</td>
          <td class="text-center"></td>
        </tr>
      </tbody>
    </table>

  </div>
</div>